﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NhibernateSample.Data;
using NhibernateSample.Domain;
using System.IO;
using System.Reflection;
using System.Xml;

namespace NhibernateSample.WinForm
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			// 1. add a new customer
			Customer customer = new Customer();
			customer.Version = 1;
			customer.FirstName = "FirstName";
			customer.LastName = "LastName";

			CustomerHelper customerHelper = new CustomerHelper();
			int newCustomerId = customerHelper.CreateCustomer(customer);

			// 2. query the new customer from database
			Customer queryCustomer = customerHelper.GetCustomerById(newCustomerId);
			MessageBox.Show(string.Format("The query customer's info: id={0}, version={1}, FirstName={2}, LastName={3}."
				, queryCustomer.Id, queryCustomer.Version, queryCustomer.FirstName, queryCustomer.LastName));
			
		}

		private void button2_Click(object sender, EventArgs e)
		{
			ServiceReference1.Service1SoapClient client = new NhibernateSample.WinForm.ServiceReference1.Service1SoapClient();
			int newCustomerId = client.AddCustomer("web service", "", 2);

			MessageBox.Show(string.Format("id:{0}", newCustomerId));
		}
	}
}
